package com.zygh.policeasset.controller;

import com.alibaba.fastjson.JSONObject;
import com.zygh.policeasset.component.CommonResult;
import com.zygh.policeasset.pojo.BingDistribution;
import com.zygh.policeasset.service.QrCodeInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping({"/qrCodeInfo"})
@Api(tags = {"二维码信息管理"})
@RestController
/* loaded from: police-asset-2.0-0.0.1-SNAPSHOT.jar:BOOT-INF/classes/com/zygh/policeasset/controller/QrCodeInfoController.class */
public class QrCodeInfoController {
    @Autowired
    QrCodeInfoService qrCodeInfoService;

    @PostMapping({"/delete"})
    @ApiOperation("删除")
    public Object delete(@RequestBody JSONObject json) {
        if (this.qrCodeInfoService.delete(json.getString("ids")).intValue() > 0) {
            return new CommonResult().success();
        }
        return new CommonResult().validateFailed("删除失败");
    }

    @GetMapping({"/remainCount"})
    @ApiOperation("查询剩余标牌数量")
    public Object remainCount() {
        return new CommonResult().success(this.qrCodeInfoService.remainCount());
    }

    @GetMapping({"/selectDistribution"})
    @ApiOperation("查询运维领取标牌")
    public Object selectDistribution(String userName) {
        return new CommonResult().success(this.qrCodeInfoService.selectDistribution(userName));
    }

    @GetMapping({"/selectDistributionByUserId"})
    @ApiOperation("查询运维领取标牌详情")
    public Object selectDistributionByUserId(Integer userId) {
        return new CommonResult().success(this.qrCodeInfoService.selectDistributionByUserId(userId));
    }

    @PostMapping({"/distribution"})
    @ApiOperation("运维领取标牌绑定")
    public Object distribution(@RequestBody BingDistribution bingDistribution) {
        return new CommonResult().success(this.qrCodeInfoService.distribution(bingDistribution));
    }
}